/*
{
"状态":1,
"名称":"获取-用户信息列表",
"作者":"马学兵",
"创建时间":"2018-08-02",
"功能":"获取-用户信息列表",
"log": [
	{"date":"06-01" , "dev" :"hzhh" , "content" : ""}
]
}
*/
declare @sql nvarchar(max)
declare @user_name varchar(100)
declare @company_key int
declare @where varchar(max)
set @user_name = '{user_name}'
set @company_key = '{company_key}'

set @where = ''
set @where += ' and company_key = @company_key'
if isnull(@user_name,'')<>''
begin
	set @user_name='%'+@user_name+'%'
	set @where += ' and (user_name like @user_name or simple_code like @user_name)'
end
set @sql = 'select Top 50 user_key,user_name from y_user where 1=1 '

SET @sql+=@where

EXEC sp_executesql @sql,N'@company_key int,@user_name varchar(100)',@company_key,@user_name